Typesetting {\tenbxsl APL\/} Arrays

The interpreter usually displays arrays as text matrices on the screen. For example, the matrix $\APLX$ is displayed as:


\begin{APLarray}
\leavevmode\hbox to 1.2em{\hss\APLspace\hss}\leavevmode\hbox to...
...space\hss}\leavevmode\hbox to 1.2em{\hss
\APLC\hss}
\APLspace\par
\end{APLarray}

The above printout is typeset by the following code which is automatically produced by the APL front end:

% AR1 X
\begin{APLarray}
\APLmb{\APLspace}\APLmb{\APLone}
\APLmb{\APLspace}\APLmb{\APLtwo}
\APLmb{\APLspace}\APLmb{\APLspace}
\APLmb{\APLspace}\APLmb{\APLA}
\APLspace\par
  ...
\end{APLarray}

Note that the structure of $\APLX$ has been preserved by automatically enforcing fixed spacing. A closer examination of the code reveals that we have simulated fixed spacing by boxing each character of the array (\APLmb does this).

Experienced APL programmers recognize the structure of $\APLX$ at the first glance: $\APLX$ is a two by two matrix whose upper left element is a two by two matrix. However, since the use of nested arrays is typical for second generation APLs like APL2 and Dyalog APL, another representation of arrays exists which shows the structure in a more explicit manner:


\begin{APLarray}
\leavevmode\hbox to 1.2em{\hss\APLdot\hss}\leavevmode\hbox to 1...
...ar\hss}\leavevmode\hbox to 1.2em{\hss\APLquote\hss}
\APLspace\par
\end{APLarray}

Most of the work for typesetting the boxed representation of $\APLX$ shown above is done by the APL function which usually comes with the APL system (e.g. [IBM 85]). Our APL front end just translates the characters generated by this function; the same LATEX environment is used for both array representations. We only sketch the code for the boxed representation:

{\it
\begin{APLarray}
\APLmb{\APLdot}\APLmb{\APLrightarrow}
\APLmb{\APLbar}\APLmb{\APLbar}
  ...
\end{APLarray}
}

In order to demonstrate the ease of changing type styles we have decided to put the generated code unit into an italics environment. This is the reason for all letters and numbers in the boxed representation being in italics. Otherwise, they would have been roman.